<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('上传文件资料')" />
    <th:block th:include="include :: jasny-bootstrap-css" />
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>上传文件资料</h5>
                </div>
                <form id="form-img-add" method="post"  enctype="multipart/form-data">
                    <input type="hidden" id="source" name="source" th:value="${source}">
                    <div class="ibox-content">
                        <div class="form-group">
                            <label class="font-noraml">选择资料:</label>
                            <div class="fileinput fileinput-new input-group" data-provides="fileinput">
                                <div class="form-control" data-trigger="fileinput"><i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename"></span></div>
                                <span class="input-group-addon btn btn-white btn-file"><span class="fileinput-new">选择文件</span><span class="fileinput-exists">更改</span><input required accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" type="file" id="file" name="file"></span>
                                <a href="#" class="input-group-addon btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: jasny-bootstrap-js" />
<script th:inline="javascript">
    function submitHandler() {
        var urls = ctx + "ReportMerchant/uploadMerchant";
        var data = new FormData();
        data.append("file", document.getElementById("file").files[0]);
        data.append("source", $("#source").val());
        $.ajax({
            url: urls,
            data: data,
            type: "post",
            dataType: "json",
            cache: false,
            processData: false,
            contentType: false,
            beforeSend: function () {
                $.modal.loading("正在处理中，请稍后...");
             },
            success: function (result) {
                if (result.code == '0') {
                    $.operate.successCallback(result);
                }else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            }
        })
    }
</script>
</body>
</html>
